"use client"; import { GroupType, PrizeTypes } from "@/api/home"; import Box from "@/components/Box"; import { useRouter } from "@/i18n/routing"; import { useSystemStore } from "@/stores/useSystemStore"; import { Toast } from "antd-mobile"; import clsx from "clsx"; import { useTranslations } from "next-intl"; import { FC, useState } from "react"; import { Swiper, SwiperSlide } from "swiper/react"; import HomeGames from "./HomeGames"; // import HomePrize from "./HomePrize"; const buttonGroup = [ { icon: "qianbao3", category_name: "sixth", isHot: false, url: "/freeGames", locale: true, lock: false, isAnimation: true, image: "/home/free.png", }, { icon: "qianbao3", category_name: "seventh", isHot: false, url: "/replayGames", locale: true, lock: false, image: "/home/replay.png", }, { icon: "liwulipinjiangpin", category_name: "first", isHot: true, url: "/promo", locale: true, lock: false, image: "/home/promoto.png", }, // { // icon: "pro-youxi1", // category_name: "second", // isHot: false, // url: "/gameList/110", // locale: true, // lock: true, // }, // { // icon: "huodongyule", // category_name: "third", // isHot: false, // url: "/sports", // locale: true, // lock: false, // }, { icon: "shipin", category_name: "fourth", isHot: false, url: "/gameList?gameListFlag=10&type=1&bet_type=1&name=live", locale: true, lock: false, image: "/home/live.png", }, { icon: "yingyong", category_name: "Fifth", isHot: false, url: "/download", locale: true, lock: false, image: "/home/app.png", }, ] as const; type TabItemType = (typeof buttonGroup)[number] & GroupType; const TabItem = ({ item, active, onClick, }: { item: TabItemType; active?: boolean; onClick?: (item: TabItemType) => void; }) => { const t = useTranslations("ButtonGroup"); const router = useRouter(); const handler = (item: TabItemType) => { if (!item.locale) { onClick && onClick(item); return; } if (item.lock) { Toast.show("It is under development."); } else { router.push(item.url); } }; const cls = clsx("pro-iconfont text-[.34rem]", `pro-${item.icon}`); // const cls2 = clsx("iconfont text-[.34rem]", `icon-${item.icon}`); const rootCls = clsx( "relative flex flex-1 cursor-pointer items-center flex-col", active ? "text-[#d0f5fb]" : "text-[#d0f5fb]" ); return (
handler(item)}>
{!item.image && } {item.image && ( {item.url} )}
{item.locale ? t(item.category_name) : item.category_name} {/* {item.isHot && ( )} */}
); }; interface Props { tabs: GroupType[]; prize?: PrizeTypes[]; } const Tabs: FC = (props) => { const { tabs, prize } = props; const { show_again_game, show_free_game } = useSystemStore((state) => { return { show_again_game: state.show_again_game, show_free_game: state.show_free_game, }; }); const newButtonGroup = buttonGroup.filter((item: any) => { if (item.url === "/freeGames" && show_free_game !== 1) { return false; } if (item.url === "/replayGames" && show_again_game !== 1) { return false; } return true; }); const tabData = [...tabs, ...newButtonGroup]; const [active, setActive] = useState(0); const router = useRouter(); const selectHandler = (item: TabItemType, index: number) => { if (item.bet_type === 2 || item.bet_type === 3) { router.push( `/gameList/?gameListFlag=${item.category[0].jump_id}&type=1&bet_type=${item.bet_type}` ); return; } setActive(index); }; const groupGames = tabs[active]?.category; return ( <> {tabData?.map((group, index) => ( selectHandler(event, index)} > ))} {/* */} ); }; export default Tabs;